// for poisonous swamps.

// code given is for Move override in PlayerMobile. Code changes start at the "SwampCheck( this )" line.
// Please note that the code given closes the move override, just selecting all the code and pasting it
// at the given line will not work. You need to select the entire Move override to be replaced, or selectively
// replace the code starting at that point.

		public override bool Move( Direction d )
		{
			NetState ns = this.NetState;

			if ( ns != null )
			{
				GumpCollection gumps = ns.Gumps;

				for ( int i = 0; i < gumps.Count; ++i )
				{
					if ( gumps[i] is ResurrectGump )
					{
						if ( Alive )
						{
							CloseGump( typeof( ResurrectGump ) );
						}
						else
						{
							SendLocalizedMessage( 500111 ); // You are frozen and cannot move.
							return false;
						}
					}
				}
			}

			TimeSpan speed = ComputeMovementSpeed( d );

			if ( !base.Move( d ) )
				return false;

			m_NextMovementTime += speed;


			///////////////////////  begin playermobile Move addition


			// 'Move( Direction d )' seems to be called when the player moves.

			if ( this != null )
				SwampCheck( this );   // for poisonous swamps


			///////////////////////  end playermobile Move addition


			return true;
		}


// begin poisonous swamps


		private static void SwampCheck( PlayerMobile from )
		{

// poisonous swamps...  Mostly.

		// basic sanity checks

			if ( from == null )
				return;  // wtf? O.o;

			// don't poison staff
	//		if ( from.AccessLevel >= AccessLevel.GameMaster )
	//			return;

			// if the player is dead, don't poison them. Thanks GrayStar! :>
			if ( !from.Alive )
				return;

			// don't poison a poisoned player.
			if ( from.Poisoned )
				return;

			// no swamps on the internal map.
			if ( from.Map == Map.Internal )
				return;

			// is the player wearing swamp boots and not mounted?
			Item shoes = from.FindItemOnLayer( Layer.Shoes );
			if ( shoes != null && shoes is SwampBoots && !( from.Mounted ) )
				return;

		// find out if the player is moving over a land/terrain (ground), static/frozen (dungeon) swamp, or static/unfrozen/added swamp.

			// initialize common variables.
			Map map = from.Map;



			// is it a land/terrain swamp?
			
			Tile lt = map.Tiles.GetLandTile( from.X, from.Y );
			
			if ( IsDeepLandSwamp( lt.ID ) && lt.Z == from.Z )
			{
				if ( Utility.RandomDouble() < 0.15 )
				{
					// poison player
					from.Poison = Poison.Regular;
						
					from.SendMessage( "You were poisoned by the swamp!" );

					return;
				}
			}
			else if ( IsLightLandSwamp( lt.ID ) && lt.Z == from.Z )
			{
				if ( Utility.RandomDouble() < 0.05 )
				{
					// poison player
					from.Poison = Poison.Lesser;

					from.SendMessage( "You were poisoned by the swamp!" );

					return;
				}
			}


			// is it a static swamp?

			Tile[] tiles = map.Tiles.GetStaticTiles( from.X, from.Y );

			for ( int i = 0; i < tiles.Length; ++i )
			{
				Tile t = tiles[i];
				ItemData id = TileData.ItemTable[t.ID & 0x3FFF];
				
				int tand = t.ID & 0x3FFF;
				
				if ( t.Z != from.Z )
				{
					continue;
				}
				else if ( IsDeepStaticSwamp( tand ) )
				{
					if ( Utility.RandomDouble() < 0.15 ) // 0.15% chance
					{
						// poison player
						from.Poison = Poison.Regular;
							
						from.SendMessage( "You were poisoned by the swamp!" );

						return;
					}
				}
				else if ( IsLightStaticSwamp( tand ) )
				{
					if ( Utility.RandomDouble() < 0.05 ) // 0.05% chance
					{
						// poison player
						from.Poison = Poison.Lesser;
							
						from.SendMessage( "You were poisoned by the swamp!" );

						return;
					}
				}
			}


			// is it an added swamp?

			IPooledEnumerable eable = map.GetItemsInRange( new Point3D( from.X, from.Y, from.Z ), 0 );

			foreach ( Item item in eable )
			{
				if ( item == null || item.Z != from.Z )
				{
					continue;
				}
				else if ( IsDeepStaticSwamp( item.ItemID ) )
				{
					if ( Utility.RandomDouble() < 0.15 ) // 0.15% chance
					{
						// poison player
						from.Poison = Poison.Regular;
							
						from.SendMessage( "You were poisoned by the swamp!" );

						return;
					}
				}
				else if ( IsLightStaticSwamp( item.ItemID ) )
				{
					if ( Utility.RandomDouble() < 0.05 ) // 0.05% chance
					{
						// poison player
						from.Poison = Poison.Lesser;
							
						from.SendMessage( "You were poisoned by the swamp!" );

						return;
					}
				}
			}

			eable.Free();
		}

		private static bool IsLightLandSwamp( int itemID )
		{
			if ( itemID >= 15808 && itemID <= 15833 )
				return true;

			if ( itemID >= 15835 && itemID <= 15836 )
				return true;

			if ( itemID >= 15838 && itemID <= 15848 )
				return true;

			if ( itemID >= 15853 && itemID <= 15857 )
				return true;

			return false;
		}

		private static bool IsDeepLandSwamp( int itemID )
		{
			if ( itemID >= 15849 && itemID <= 15852 )
				return true;

			return false;
		}

		private static bool IsLightStaticSwamp( int itemID )
		{
			if ( itemID >= 12809 && itemID <= 12810 )
				return true;

			if ( itemID >= 12882 && itemID <= 12905 )
				return true;

			if ( itemID >= 12912 && itemID <= 12933 )
				return true;

			return false;
		}

		private static bool IsDeepStaticSwamp( int itemID )
		{
			if ( itemID >= 12813 && itemID <= 12881 )
				return true;

			if ( itemID >= 12906 && itemID <= 12911 )
				return true;

			return false;
		}


// end poisonous swamps